<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>iScroll demo: pull to refresh</title>

<script type="application/javascript" src="js/lib/iscroll-4.0beta4.js"></script>

<script type="text/javascript">

var myScroll, generatedRows = 0;
function loaded() {
	myScroll = new iScroll('wrapper', {
		pullToRefresh: 'both',
		onPullDown: function () {
			setTimeout(function () {
				var el, li, i;
				el = document.getElementById('thelist'),

				for (i=0; i<3; i++) {
					li = document.createElement('li');
					li.innerText = 'Generated row ' + (++generatedRows);
					el.insertBefore(li, el.childNodes[0]);
				}

				myScroll.refresh();		// IMPORTANT!
			}, 1000);	// <-- Simulate network congestion, remove setTimeout from production!
		},
		onPullUp: function () {
			setTimeout(function () {
				var el, li, i;
				el = document.getElementById('thelist'),

				for (i=0; i<3; i++) {
					li = document.createElement('li');
					li.innerText = 'Generated row ' + (++generatedRows);
					el.appendChild(li);
				}

				myScroll.refresh();		// IMPORTANT!
			}, 1000);	// <-- Simulate network congestion, remove setTimeout from production!
		}

	});
}

document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

document.addEventListener('DOMContentLoaded', loaded, false);

</script>

<style type="text/css" media="all">
body,ul,li {
	padding:0;
	margin:0;
	border:0;
}

body {
	font-size:12px;
	-webkit-user-select:none;
    -webkit-text-size-adjust:none;
	font-family:helvetica;
}

#header {
	position:absolute;
	top:0; left:0;
	width:100%;
	height:45px;
	line-height:45px;
	background-image:-webkit-gradient(linear, 0 0, 0 100%, color-stop(0, #fe96c9), color-stop(0.05, #d51875), color-stop(1, #7b0a2e));
	padding:0;
	color:#eee;
	font-size:20px;
	text-align:center;
	font-weight:bold;
	text-shadow:0 -1px 0 rgba(0,0,0,0.5);
	color:#f3f3f3;
}

#footer {
	position:absolute;
	bottom:0; left:0;
	width:100%;
	height:48px;
	background-image:-webkit-gradient(linear, 0 0, 0 100%, color-stop(0, #999), color-stop(0.02, #666), color-stop(1, #222));;
	padding:0;
	border-top:1px solid #444;
}

#wrapper {
	position:absolute; z-index:1;
	top:45px; bottom:48px; left:0;
	width:100%;
	background:#aaa;
	overflow:auto;
}

#scroller {
	position:relative;
/*	-webkit-touch-callout:none;*/
	-webkit-tap-highlight-color:rgba(0,0,0,0);

	float:left;
	width:100%;
	padding:0;
}

#scroller ul {
	position:relative;
	list-style:none;
	padding:0;
	margin:0;
	width:100%;
	text-align:left;
}

#scroller li {
	padding:0 10px;
	height:40px;
	line-height:40px;
	border-bottom:1px solid #ccc;
	border-top:1px solid #fff;
	background-color:#fafafa;
	font-size:14px;
}

#scroller li > a {
	display:block;
}


/**
 *
 * Styles specific to the pull down/up element
 *
 */
.iScrollPullDown,
.iScrollPullUp {
	background:#fff;
	border-bottom:1px solid #aaa;
	height:40px;
	line-height:40px;
	padding:5px 10px;
	font-size:14px;
	color:#999;
	font-weight:bold;
	-webkit-transform:translate3d(0,0,0);	/* Put the element in the HW accelerated layer */
}

.iScrollPullDownIcon,
.iScrollPullUpIcon {
	display:block; float:left;
	width:40px; height:40px;
	background:url(img/pull-icon.png) 0 0 no-repeat;
	background-size:40px 80px;
	margin-right:5px;
	-webkit-transition-property:-webkit-transform;
	-webkit-transition-duration:250ms;
	-webkit-transform:rotate(0);
}

.iScrollPullDown.flip .iScrollPullDownIcon {
	-webkit-transform:rotate(-180deg);
}

.iScrollPullDown.loading .iScrollPullDownIcon,
.iScrollPullUp.loading .iScrollPullUpIcon {
	background-position:0 100%;
	-webkit-animation-name:loading;
	-webkit-animation-duration:1.5s;
	-webkit-animation-iteration-count:infinite;
	-webkit-animation-timing-function:linear;
}

.iScrollPullUp {
	border-bottom:0;
}

.iScrollPullUpIcon {
	-webkit-transform:rotate(-180deg);
}

.iScrollPullUp.flip .iScrollPullUpIcon {
	-webkit-transform:rotate(0);
}

@-webkit-keyframes loading {
	from { -webkit-transform:rotate(0deg); }
	to { -webkit-transform:rotate(360deg); }
}

@media screen and (-webkit-min-device-pixel-ratio:2) {
	.iScrollPullDownIcon,
	.iScrollPullUpIcon {
		background-image:url(img/pull-icon@2x.png);
	}
}

</style>
</head>
<body>
<div id="header">iScroll</div>

<div id="wrapper">
	<div id="scroller">
		<ul id="thelist">
			<li>Pretty row 1</li>
			<li>Pretty row 2</li>
			<li>Pretty row 3</li>
			<li>Pretty row 4</li>
			<li>Pretty row 5</li>
			<li>Pretty row 6</li>
			<li>Pretty row 7</li>
			<li>Pretty row 8</li>
			<li>Pretty row 9</li>
			<li>Pretty row 10</li>
			<li>Pretty row 11</li>
			<li>Pretty row 12</li>
			<li>Pretty row 13</li>
			<li>Pretty row 14</li>
			<li>Pretty row 15</li>
			<li>Pretty row 16</li>
			<li>Pretty row 17</li>
			<li>Pretty row 18</li>
			<li>Pretty row 19</li>
			<li>Pretty row 20</li>
			<li>Pretty row 21</li>
			<li>Pretty row 22</li>
			<li>Pretty row 23</li>
			<li>Pretty row 24</li>
			<li>Pretty row 25</li>
			<li>Pretty row 26</li>
			<li>Pretty row 27</li>
			<li>Pretty row 28</li>
			<li>Pretty row 29</li>
			<li>Pretty row 30</li>
			<li>Pretty row 31</li>
			<li>Pretty row 32</li>
			<li>Pretty row 33</li>
			<li>Pretty row 34</li>
			<li>Pretty row 35</li>
			<li>Pretty row 36</li>
			<li>Pretty row 37</li>
			<li>Pretty row 38</li>
			<li>Pretty row 39</li>
			<li>Pretty row 40</li>
		</ul>
	</div>
</div>

<div id="footer"></div>

</body>
</html>